<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<script type="text/javascript">
    function dormBuildDeleteOrActive(dormitorieId) {
        if(confirm("您确定要删除这个寝室吗？")) {
            location.href="${pageContext.request.contextPath}/dormBuild/deleteDorm?id="+dormitorieId;
        }
    }

</script>
<div class="data_list">
    <div class="data_list_title">
        <a style="margin-right: 20px;" href="${pageContext.request.contextPath}/dormBuild/findDormBuildList">宿舍楼管理</a>
        <a style="margin-right: 20px;" href="${pageContext.request.contextPath}/dormBuild/findDormitoryList">寝室管理</a>
        <a style="margin-right: 20px;" href="${pageContext.request.contextPath}/dormManager/findAll">员工管理</a>
    </div>
    <form name="myForm" class="form-search" method="post" action="${pageContext.request.contextPath}/dormBuild/findDormitoryList">
        <button class="btn btn-primary" type="button" style="margin-right: 50px;" onclick="location.href='${pageContext.request.contextPath}/dormBuild/addDormitory?para=add'">添加</button>
        <span class="data_search">
                寝室号  <input id="number" name="number" value="" type="text"  style="width:120px;height: 30px;" class="input-medium search-query">
					<select id="conditions" name="conditions" onchange="popupDorm()" style="width: 120px;">
                        <option value="buildName">楼号</option>
					</select>
                    &nbsp;<input id="information" name="information" type="text" value="${keyword}" style="width:120px;height: 30px;" class="input-medium search-query" >
					&nbsp;<button type="submit" class="btn btn-info">搜索</button>
				</span>
    </form>
    <div>
        <table class="table table-striped table-bordered table-hover datatable">
            <thead>
            <tr>
                <th width="15%">宿舍号</th>
                <th>所属楼号</th>
                <th>可容纳人数</th>
                <th>实际入住人数</th>
            </tr>
            </thead>
            <tbody>
            <c:forEach  items="${dormitories}" var="dormitorie">
                <tr>
                    <td>${dormitorie.number}</td>
                    <td>${dormitorie.building.name}</td>
                    <td>${dormitorie.capablePeople}</td>
                    <td>${dormitorie.actualPeople}</td>
                    <td>
                        <button class="btn btn-primary" type="button" onclick="location.href='${pageContext.request.contextPath}/student/findAll?conditions=buildingname_dormname&information=${dormitorie.building.name}&number=${dormitorie.number}'">查看所住的学生</button>
                        <button class="btn btn-primary" type="button" onclick="location.href='${pageContext.request.contextPath}/dormBuild/findOneDorm?dormID=${dormitorie.id}'">修改</button>&nbsp;
                        <button class="btn btn-primary" type="button" onclick="dormBuildDeleteOrActive(${dormitorie.id})">删除</button>
                    </td>
                </tr
            </c:forEach>

            </tbody>
        </table>
    </div>
    <div align="center"><font color="red"></font></div>
</div>
